package com.xy.modular.owner.controller;
import com.xy.framework.mreturn.MReturnObject;
import com.xy.modular.owner.model.OwnerRole;
import com.xy.modular.owner.service.IOwnerRoleService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 *
 * Created by BCK on 2019/09/14.
 */
@Controller
@RequestMapping("/OwnerRole/")
public class OwnerRoleController {

    @Resource
    IOwnerRoleService ownerRoleService;

    @RequestMapping("add")
    @ResponseBody
    public String add(OwnerRole OwnerRole) {
    	ownerRoleService.save(OwnerRole);
        return "";
    }

    @RequestMapping("delete")
    @ResponseBody
    public String delete(@RequestParam String id) {
    	ownerRoleService.deleteById(id);
	    return "";
    }

    @RequestMapping("update")
    @ResponseBody
    public String update(OwnerRole OwnerRole) {
    	ownerRoleService.update(OwnerRole);
	    return "";
    }

    @RequestMapping("detail")
    @ResponseBody
    public String detail(@RequestParam String id) {
        OwnerRole OwnerRole = ownerRoleService.getById(id);
        return OwnerRole.toString();
    }

    @RequestMapping("list")
    @ResponseBody
    public MReturnObject list(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size) {
        return new MReturnObject(MReturnObject.SUCCESS, ownerRoleService.findAll());
    }
}
